﻿using System;
using System.Collections.Specialized;
using System.Runtime.Serialization;

namespace SyCODE.Blog.Task
{
    /// <summary>
    /// 任务结构定义
    /// </summary>
    [Serializable]
    public abstract class TaskBase : ISerializable
    {
        /// <summary>
        /// 任务执行过程中的参数键值对
        /// </summary>
        protected NameValueCollection Params;

        /// <summary>
        /// 序列化接口的实现
        /// </summary>
        /// <param name="info">要填充数据的 System.Runtime.Serialization.SerializationInfo</param>
        /// <param name="context">序列化的目标</param>
        public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("params", this.Params);
        }

        /// <summary>
        /// 任务的执行方法
        /// </summary>
        public abstract void Execute();
    }
}